<template>
  <div class="banner">
    <van-swipe :autoplay="3000" :show-indicators="show_indicators">
      <van-swipe-item v-for="image in banner_list" :key="image.id">
        <img v-lazy="image.picUrl" />
      </van-swipe-item>
    </van-swipe>


    <div class="nav">
      <ul>
        <li><img src="../../public/images/爱心.png" alt="爱心">
          <p @click="gotosign">签到</p>
        </li>
        <li><img src="../../public/images/星星.png" alt="星星">
          <p @click="gotocoupon">礼券</p>
        </li>
        <li><img src="../../public/images/皇冠.png" alt="皇冠">
          <p @click="gotobargainlist">砍价</p>
        </li>
        <li><img src="../../public/images/吊灯.png" alt="吊灯">
          <p @click="gotosubjectlist">专栏</p>
        </li>

      </ul>
    </div>
  </div>
</template>

<script>
  import Vue from 'vue';
  import {
    Lazyload
  } from 'vant';

  Vue.use(Lazyload);
  export default {
    data() {
      return {
        banner_list: [],
        show_indicators: false
      }
    },

    methods: {
      gotosign() {
        this.$router.push(this.$path.SIGN)
      },
      gotocoupon() {
        this.$router.push(this.$path.COUPON)
      },
      gotobargainlist() {
        this.$router.push(this.$path.BARGAINLIST)
      },
      gotosubjectlist() {
        this.$router.push(this.$path.SUBJECTLIST)
      },
    },

    mounted() {
      this.$API.banner_list().then((res) => {
        // console.log(res);
        this.banner_list = res.data.data
        // console.log(this.banner_list);
      }).catch((err) => {
        console.log(err);
      });
    },
  }
</script>

<style lang="scss" scoped>
  .banner {
    width: 100vw;
    height: 50vh;
    position: relative;

    .van-swipe {
      width: 100vw;
      height: 50vh;

      img {
        width: 100vw;
        height: 100%;
        background-color: #fff;
      }
    }

    .nav {
      border-radius: 45px 45px 0 0;
      width: 100vw;
      height: 10vh;
      background-color: rgba($color: #000000, $alpha: 0.2);
      position: absolute;
      bottom: 0;

      ul {
        width: 100vw;
        height: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;

        li {
          flex: 1;
          text-align: center;

          img {
            width: 7vw;
            height: 4vh;
            margin-bottom: 1vh;
          }

          font-size: 14px;
          font-weight: bold;
        }
      }
    }
  }
</style>